/*
	Esta libreria contiene funciones que solo sirven para encapsular las tareas de inicializacion de SDL.	
*/

#include "SDL/SDL.h"
//#include "stdlib.h"
//#include "SDL/SDL_image.h"

using namespace std;
#include <iostream>
#include <vector>
#include <cmath>

SDL_Surface *screen;
Sint32 verGrafo;

Uint32 dibujo(Uint32 intervalo, void *parametros)
{
		
}

/*
*	Dibuja un bitmap en otro bitmap
*/
void dibujarBitmap(SDL_Surface *frame, SDL_Surface *destino,  float pos_x, float pos_y, float pos_z)
	{
		
		SDL_Rect dest, escala;
		escala.x = (Sint16)0;		
		escala.y = (Sint16)0;
		escala.w = (Sint16)frame->w;
		escala.h = (Sint16)frame->h;
		
		dest.x = (Sint16)pos_x;		
		dest.y = (Sint16)pos_y;
		dest.w = (Sint16)frame->w;
		dest.h = (Sint16)frame->h;
		
		SDL_BlitSurface(frame, &escala, destino, &dest);
}

Uint32 iniciaTiempo()
{
	SDL_TimerID mytimer;

	mytimer = SDL_AddTimer(1000, dibujo, screen);

	if(mytimer == NULL)
	{
		cerr << "No se pudo establecer el timer: "<< SDL_GetError();
		exit(1);
	}
	return 0;
}

Uint32 iniciaVideo()
{
	
	if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO|SDL_INIT_TIMER) < 0) cout << ":( error al iniciar SDL: %s\n" << SDL_GetError() << endl;

	atexit(SDL_Quit);
	screen = SDL_SetVideoMode(800, 600, 24, SDL_HWSURFACE|SDL_DOUBLEBUF);
	if (screen == NULL) cout << "Error al setear el modo de video :(  %s\n"<< SDL_GetError() << endl;

	SDL_WM_SetCaption("25 ", NULL);
	
	//SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
		SDL_EnableKeyRepeat(1, 1);
	return 0;
}





